

*******************************************************************************
* This file plots aggregate trends
*******************************************************************************

global folder ".."

use "$folder/data_input/haircut_plot_data.dta", clear


gen quarter = mod(yq, 10)
gen year = (yq - quarter)/10
replace year = int(year)
replace quarter = int(quarter)
gen temp = string(year) + "Q" + string(quarter)
drop yq
rename temp yq

gen qdate = quarterly(yq, "YQ")
tsset qdate

keep if year>=2011


graph twoway (tsline vwavg_bond_IRC , lpattern(solid) lcolor(blue) lwidth(medium)) ///
(tsline avg_trea_bas , lpattern(dash) lcolor(sand) lwidth(medium)) ///
(tsline vwavg_muni_IRC , lpattern(dot) lcolor(green) lwidth(medium)) ///
(tsline vwavg_eq_PQS , lpattern(dash_dot) lcolor(red) lwidth(medium)), ///
legend(label(1 "Corporate bonds") label(2 "Treasury bonds") label(3 "Municipal bonds") label(4 "Stocks")) ///
xlabel(204(4)229, format(%tq))  ///
ytitle("Liquidation costs (bps)") ///
title("") ///
xtitle("") ///
plotregion(color(white)) graphregion(color(white)) ///
ylab(, nogrid) xlab(, nogrid)
graph export "$folder/output/bid_ask_spreads.pdf", replace


sum vwavg_bond_IRC vwavg_muni_IRC avg_trea_bas vwavg_eq_PQS



use "$folder/data_input/haircut_others_plot_data.dta", clear

graph twoway (tsline spread_com_loan , lpattern(solid) lcolor(blue) lwidth(medium)) ///
(tsline spread_cmoabs , lpattern(dash) lcolor(sand) lwidth(medium)) ///
(tsline spread_ag_mbscmo , lpattern(dot) lcolor(green) lwidth(medium)) ///
(tsline spread_ag_deb , lpattern(dash_dot) lcolor(red) lwidth(medium)), ///
xlabel(204(4)229, format(%tq))  ///
ytitle("Liquidation costs (bps)") ///
legend(label(1 "Loans") label(2 "ABS") label(3 "Agency MBS") label(4 "Agency debt") ) ///
title("") ///
xtitle("") ///
plotregion(color(white)) graphregion(color(white)) ///
ylab(, nogrid) xlab(, nogrid)
graph export "$folder/output/bid_ask_spreads_others.pdf", replace


